<template>
  <div>
    <div class="box">
      <img :src="imgurl" alt="" />
      <p :style="{ backgroundColor: ranDow }" @click="Fn">{{ dogname }}</p>
    </div>
  </div>
</template>

<script>
export default {
  props: ["imgurl", "dogname"],
  data() {
    return {
      ranDow: "",
    };
  },
  methods: {
    Fn() {
      this.ranDow = `rgb(${Math.floor(Math.random() * 256)}, ${Math.floor(
        Math.random() * 256
      )}, ${Math.floor(Math.random() * 256)})`;
    },
  },
};
</script>

<style>
.box {
  float: left;
  text-align: center;
  width: 400px;
  height: 500px;
  border: 1px solid black;
}
img {
  width: 100%;
  height: 400px;
}
</style>